<template>
    <div>
        <h1>新增康复理疗信息</h1>
        <table>
        <tbody>
            <tr>
                <td>项目名称<span style="color: red;">*</span></td>
                <td><input type="text" v-model="list.jname"></td>
            </tr>
            <tr>
                <td>服务人数<span style="color: red;">*</span></td>
                <td><input type="text" v-model="list.person"></td>
            </tr>
            <tr>
                <td>服务时长<span style="color: red;">*</span></td>
                <td><input type="text" v-model="list.time"></td>
            </tr>
            <tr>
                <td>项目说明<span style="color: red;">*</span></td>
                <td><textarea v-model="list.jsm"></textarea></td>
            </tr>
            <tr>
                <td>状态<span style="color: red;">*</span></td>
                <td>
                    <input type="radio" v-model="list.start" value="true" checked>启用
                    <input type="radio" v-model="list.start" value="falase" >禁用
                </td>
            </tr>
            <tr>
                <td>删除状态<span style="color: red;">*</span></td>
                <td>
                    <input type="radio" v-model="list.iDelet" value="true" checked>true
                    <input type="radio" v-model="list.iDelet" value="falase" >falase
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="保存" @click="Add"></td>
                <td></td>
            </tr>
         
        </tbody>
     </table>
    </div>
</template>

<script setup lang="ts">
import{ref,onMounted}from"vue";
import axios from "axios";
import { useRouter } from "vue-router";
const router=useRouter();
const list=ref({
    "jid": 0,
  "jstring": "string",
  "jname": "string",
  "person": 0,
  "time": 0,
  "jsm": "string",
  "start": true,
  "iDelet": true
})

const Add=()=>{
    if(list.value.jname==""){
        alert('项目名称不能为空')
        return;
    }
    if(list.value.person*1==0){
        alert('服务人数不能为空')
        return;
    }
    if(list.value.time*1==0){
        alert('服务时长不能为空')
        return;
    }
    if(list.value.jsm==""){
        alert('项目说明不能为空')
        return;
    }
   
    axios.post('https://localhost:7084/api/Jkang/Add',list.value).then(res=>{
         if(res.data>0){
            alert('添加成功');
            router.push({
                    path:"/JShow"
                })
         }else{
            alert('添加失败');
         }
    })
}

</script>

<style scoped>

</style>